package sslf.com.dao;

import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;

import sslf.com.domain.Test;
import sslf.com.domain.User;

@Repository
public class TestDao extends BaseDao{
	
	public User select(){
		User u = new User();
		System.out.println("jdbcT:"+this.getJdbcTemplate());
		JdbcOperations jdbc = this.getJdbcTemplate().getJdbcOperations();
		int a  = jdbc.queryForInt("select count(*) as userId  from user ");
		u.setUserId(a);
		return u;
	}
	
	public boolean insert (){
		Test t = new Test(8,"testName","重庆"); 
		SqlParameterSource param = new BeanPropertySqlParameterSource(t);
		int a = this.getJdbcTemplate().update("insert into test(id,name,sys) values(:id,:name,:sys)", param);
		return a > 0 ?true:false;
	}
}
